home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / d86.arc / MAIN.DOC < prev    next >
Encoding:
Text File  |  1986-08-29  |  10.5 KB  |  230 lines

  1. ---MAIN.DOC---
  2.  
  3. Invoking the D86 Debugger
  4.  
  5. D86 is the screen-oriented symbolic debugger used with programs assembled
  6. under the assembler A86.   D86 runs on an MS-DOS system, with an IBM-compatible
  7. monochrome or color-graphics video interface.
  8.  
  9. You invoke D86 by issuing the command
  10.  
  11.    D86 [-V] [progname [command-tail]]
  12.  
  13. where progname.SYM and progname.COM are the symbols and output files of the A86
  14. assembler.  In other words, you simply provide the program invocation line,
  15. with the word D86 appended to the start.
  16.  
  17. It is not necessary for progname.SYM to be present.  If it is not, then the
  18. debugger simply comes up with no user symbols defined.
  19.  
  20. You can also invoke D86 with no progname.  The debugger comes up with no
  21. program loaded, allowing you to simply poke around the machine.
  22.  
  23. If you don't see symbols, or you don't see your program in memory, then D86
  24. had some problem loading your files.  The later, product-quality version of
  25. D86 will tell you this explicitly, but right now you simply have to deduce it.
  26.  
  27. The -V option can be used if you have both a monochrome and a color monitor.
  28. If you specify -V, the debugger will appear on whichever screen is NOT currently
  29. selected.  This allows you to see both the debugger output and the program
  30. output at the same time.
  31.  
  32.  
  33. The D86 Screen Display
  34.  
  35. When D86 starts up, it generates a full-screen display, and awaits your
  36. debugger commands.
  37.  
  38. In the top part of the screen is a symbolic disassembly of the A86 program,
  39. with the screen cursor positioned next to the instruction pointed to by the
  40. 8086 instruction pointer.
  41.  
  42. In the lower right corner is a fixed display of the complete 8086 register set.
  43.  
  44. At the top of the second column of the register-set display is a display of the
  45. 8086 flags.  Each flag displays as blank if the flags is off; and a lower-case
  46. letter if the flag is on:
  47.           "o" for overflow,
  48.           "d" for direction,
  49.           "i" for interrupts enabled,
  50.           "s" for sign,
  51.           "z" for zero,
  52.           "a" for auxiliary carry,
  53.           "p" for parity even, and
  54.           "c" for carry.
  55.  
  56. Across the bottom line of the screen is a display of the contents of the user
  57. stack.  The display begins next to the SP register value, with the number of
  58. elements on the stack.  (The stack is assumed to have 0 elements when SP is at
  59. its original value, 0FFFE). The number of elements is followed by a colon,
  60. followed by as many of the top stack elements as fits on the line.  The
  61. initial display will have zero elements; nothing is yet on the stack.
  62.  
  63. To the right of the registers are 6 lines, numbered 1 through 6.  On these
  64. lines, you can generate windows into 8086 memory, displaying bytes, words,
  65. or ASCII text in a variety of formats. The windows can be located either at
  66. absolute memory locations, or be pointed to by any of the 8086 registers.  The
  67. commands you issue to generate these windows are described in the next section.
  68.  
  69.  
  70.  
  71. D86 Commands
  72.  
  73. There are 5 kinds of activities you perform in D86:
  74.  
  75.    1. Issuing assembly-language commands for immediate execution
  76.    2. Issuing debugger commands via lines that begin with a single letter
  77.    3. Issuing debugger commands via the function and edit keys on your keyboard
  78.    4. Setting up windows displaying memory
  79.    5. Issuing assembly-language commands to enter into memory (PatchMem)
  80.  
  81.  
  82.  
  83. Immediate Assembly-Language Commands
  84.  
  85. A primary part of the D86 command language is the A86 assembly language. With
  86. it, you can jump to different areas of your program, set your registers,
  87. perform arithmetic, and call any of the procedures of your program.  Simply
  88. type in any legal A86 instruction, and it will be executed immediately.
  89.  
  90. JMP and RET instructions cause the program counter (and thus also the
  91. disassembly) to move to the indicated destination.  CALL instructions cause
  92. the entire procedure to be executed.
  93.  
  94. WARNING: The immediate-execution feature is a little tricky if you are in
  95.   a multi-segment program, of if you jump to exotic parts of the 86 memory
  96.   space (i.e., into MSDOS, ROM, video memory, or the interrupts table).
  97.   This is because D86 needs a buffer in which to put the immediate-execution
  98.   command.  The buffer should be in your program's CS segment, so that commands
  99.   such as jumps and near calls execute correctly.  So D86 must always search
  100.   in CS for a satisfoactory buffer.  Here is how D86 finds it:
  101.  
  102.   1. If you declare a label D86_BUFFER, pointing to a buffer within your
  103.      program, then D86 will use that buffer as the offset for its immediate
  104.      instruction.
  105.  
  106.   2. If not, then if the program's CS register is the same as its SS register,
  107.      D86 will use (SP-300) as its immediate buffer.  Thus, our stack should
  108.      have plenty of room (a good practice in general).
  109.  
  110.   3. As a last resort, D86 uses offset 00E0, which points to the last 32 bytes
  111.      of the Program Segment Prefix (PSP).  In that case, if you were to issue
  112.      an immediate command that read from a disk file, you would be in trouble,
  113.      because the disk-read operation clobbers the PSP, and the command would
  114.      then not be trapped back to the debugger.
  115.  
  116.   In cases 1 and 3 above, the segment containing the buffer is the program's
  117.   CS segment, unless that is out of range (below the program's original CS,
  118.   or above the top of available program memory).  If the program CS is out of
  119.   range, the program's original CS is used instead.  In that case, immediate
  120.   instructions such JMP, RET, and CALL will not work correctly.
  121.  
  122.   Note that the above caveats to not apply to single-stepping.
  123.  
  124.  
  125.  
  126. Entering Instructions Into Memory
  127.  
  128. D86 allows you to alter 8086 memory in two ways: first, you can issue
  129. immediate assembly language commands which, when executed, store values in
  130. memory.  The other method is to enter a special mode, in which you enter
  131. instructions directly into 8086 memory.
  132.  
  133. You enter this mode by typing the F7 (PatchMem) key. The screen cursor jumps
  134. from the left edge of the line at the current program counter, into the middle
  135. of the line where the instruction is.  You start typing over the instruction,
  136. to signal that you are clobbering the instruction that was there.  If you did
  137. not intend to enter this mode, you can backspace back to the start of the
  138. instruction, and type a carriage-return.
  139.  
  140. Each line you type in is checked for errors.  If there was an error, a message
  141. is displayed, the cursor remains at the same location, and you try again.
  142. If there was no error, the cursor moves beyond the newly-assembled line, and
  143. you can type in another line.
  144.  
  145. To exit the memory-programming mode, you type any of the control-key commands
  146. at the beginning of the line.  (Type carriage-return if you don't want any
  147. actions to be performed.)
  148.  
  149.  
  150. Entering Data into 8086 Memory
  151.  
  152. You can deposit data into the 8086 memory space by using the programming mode
  153. described in the above section.  Simply enter DB and/or DW statements instead
  154. of instructions.  Note that ASCII strings can be entered with the DB
  155. instruction; and that arrays can be initialized via the DUP operator in a DB
  156. or DW statement.
  157.  
  158.  
  159. Adding Symbols to a Program
  160.  
  161. Patch-mode also allows you to do something that you cannot do in immediate-
  162. execution mode: add symbols to the program.  You can do so by either:
  163.  
  164.    1. Typing in a new symbol-name, followed by a colon; or
  165.    2. Typing in an EQU directive.
  166.  
  167. There are several uses for this.  First, you might want to create an
  168. abbreviation, by equating a short name to a long one, or to a hard-to-remember
  169. constant value.  Second, you might want to "reverse engineer" a program for
  170. which you have a .COM file, but not the A86 source code.  Each time you add a
  171. label, the disassembly becomes more readable.  Third, you might want to label
  172. code which you have added in patch-mode.
  173.  
  174. Starting with V2.16, forward referencing is now allowed when you are in patch
  175. mode.  You must be careful, however, to reslove any forward references you have
  176. made.  In particular, you will cause the assembler to become very confused (and
  177. possibly trash random memory) if you overwrite a forward reference with some
  178. other code before you resolve the reference.  So don't!
  179.  
  180.  
  181. D86 Control-Key Functions
  182.  
  183. D86 has a set of functions invoked by single keys, which can be invoked any
  184. time D86 is awaiting the beginning of an assembly-language command.
  185.  
  186. F1           Single-step the current instruction.  If the instruction is a call,
  187.              go into the procedure to single-step it.  If you want the entire
  188.              procedure executed on a single keystroke, use the F2 key.
  189.  
  190. F2           Procedure-step: start program, trapping at the instruction
  191.              following the current one.  This is used for executing a procedure
  192.              call all at once; for breaking out of a loop; and for executing
  193.              a repeated string operation all at once.
  194.  
  195. F3           Repeat the last typed-in assembly language or debugger command
  196.  
  197. F4           Start the program, setting a trap at the destination of the
  198.              conditional-jump instruction currently pointed to.  If we are not
  199.              pointing to a conditional jump, then we single-step.
  200.  
  201. F6           Start the program, setting a trap at the address on top of the
  202.              stack (hopefully a procedure-return address).
  203.  
  204. F7           Enter the previously-described Patch Memory mode.
  205.  
  206. Alt-F9       If you have a Color video board, your debugger display may become
  207.              corrupted by the program's console output.  If it does, press
  208.              Alt-F9 to eliminate the corruption.  This key exists only
  209.              temporarily; on later versions of D86, the corruption will be
  210.              corrected automatically.
  211.  
  212. F10          When you are in Help-Mode, this key gives you alternate help
  213.              windows in some contexts.  When you are not in Help-Mode, this
  214.              key toggles though the display windows: in this preliminary
  215.              debugger, that is just the sign-on message and a blank window.
  216.  
  217. Down-arrow   Jump to the instruction following the current one, without
  218.              executing the current instruction.
  219.  
  220. Up arrow     "Up": decrement the current program counter.
  221.  
  222. Pg Dn        Jump to the next disassembly page, without executing.
  223.  
  224. Home         Jump to location 0100 in the current code segment.  In most
  225.              .COM programs, this will be the start of the program.  NOTE that
  226.              no other re-initializations take place with this command.  If you
  227.              wish to completely reinitialize your program, you should exit
  228.              and reenter the debugger.
  229.  
  230.